{include file="public/header" /}
<style>
    .my-upload-right{
        position: absolute;
        right: 35px;
        top: 30px;
    }
    .layui-form-item .layui-input-block.my-width{
        width: 60%;
    }
    #uoload-thumbnail.layui-btn{
        display: none;
    }
    .layui-upload-list {
        width: 280px;
        height: 190px;
    }
    .layui-upload-list-title {
        height: 190px;
        line-height: 190px;
    }
</style>
</head>
<body>
<form class="layui-form layui-form-pane" action="" style="padding: 20px;position: relative;">
    <input type="hidden" name="drawing_id" value="{$dataInfo.drawing_id|default=0}">
    <input type="hidden" name="drawing_bank_id" value="{$dataInfo.drawing_bank_id|default=0}">
    {notempty name="SUBSTATIONS"}
    <input type="hidden" name="substation_id" value="{$dataInfo.substation_id|default=$SUBSTATIONS}">
    {/notempty}
    <div class="layui-form-item">
        <label class="layui-form-label">图纸标题</label>
        <div class="layui-input-block my-width">
            <input type="text" name="topic" required lay-verify="required"  placeholder="请输入图纸标题" autocomplete="off" class="layui-input" value="{$dataInfo.topic|default=''}">
        </div>
    </div>
    <div class="layui-form-item my-width">
        <label class="layui-form-label ">标签</label>
        <div class="layui-input-inline" style="width: 50%">
            <input type="text" name="keywords"  autocomplete="off" class="layui-input" value="{$dataInfo.keywords|default=''}">
        </div>
        <button class="layui-btn" type="button" id="getKeywords">获取标签</button>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">编号</label>
        <div class="layui-input-block my-width">
            <input type="text" name="no"  required lay-verify="required"  placeholder="请输入编号" autocomplete="off" class="layui-input" value="{$dataInfo.no|default=''}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">方案</label>
        <div class="layui-input-block my-width" >
            <select name="no2" lay-search placeholder="请选择方案" required lay-verify="required">
                <option value="">请选择</option>
                {notempty name="DrawingProgramme"}
                {volist name="DrawingProgramme" id="tl"}
                <option value="{$tl.config_id}" {present name="dataInfo.no2"}{if condition="$tl['config_id'] == $dataInfo['no2']"}selected{/if}{/present}>{$tl.config_name}</option>
                {/volist}
                {/notempty}
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">分类</label>
        <div class="layui-input-block my-width" >
            <select name="cate" lay-search placeholder="请选择分类" >
                <option value="">请选择</option>
                {notempty name="DrawingType"}
                {volist name="DrawingType" id="tl"}
                <option value="{$tl.config_id}" {present name="dataInfo.cate"}{if condition="$tl['config_id'] == $dataInfo['cate']"}selected{/if}{/present}>{$tl.config_name}</option>
                {/volist}
                {/notempty}
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">框架架构</label>
        <div class="layui-input-block my-width" >
            <select name="struct" lay-search placeholder="请选择框架架构" required lay-verify="required">
                <option value="">请选择</option>
                {notempty name="DrawingFrameStructure"}
                {volist name="DrawingFrameStructure" id="tl"}
                <option value="{$tl.config_id}" {present name="dataInfo.struct"}{if condition="$tl['config_id'] == $dataInfo['struct']"}selected{/if}{/present}>{$tl.config_name}</option>
                {/volist}
                {/notempty}
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">风格</label>
        <div class="layui-input-block" >
            <select name="style" lay-search placeholder="请选择风格" required lay-verify="required">
                <option value="">请选择</option>
                {notempty name="DrawingStyle"}
                {volist name="DrawingStyle" id="tl"}
                <option value="{$tl.config_id}" {present name="dataInfo.style"}{if condition="$tl['config_id'] == $dataInfo['style']"}selected{/if}{/present}>{$tl.config_name}</option>
                {/volist}
                {/notempty}
            </select>
        </div>
    </div>
    <div class="layui-form-item" pane>
        <label class="layui-form-label">图纸属性</label>
        <div class="layui-input-block">
            {notempty name="DrawingProperty"}
            {volist name="DrawingProperty" id="tl"}
                <input type="checkbox" name="attrs[]" value="{$tl.config_id}" title="{$tl.config_name}" {if condition="in_array($tl.config_id,$dataInfo.attrs_arr)"}checked{/if}>
            {/volist}
            {/notempty}
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">价格</label>
        <div class="layui-input-block" >
            <input type="number" name="price" required lay-verify="required"  placeholder="请输入价格" autocomplete="off" class="layui-input" value="{$dataInfo.price|default=''}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">层数</label>
        <div class="layui-input-block" >
            <input type="text" name="layct" required lay-verify="required"  placeholder="请输入层数" autocomplete="off" class="layui-input" value="{$dataInfo.layct|default=''}">
        </div>
    </div>
    <div class="layui-form-item" pane>
        <label class="layui-form-label">图纸置顶</label>
        <div class="layui-input-block">
            {notempty name="RadioIs"}
            {volist name="RadioIs" id="vo"}
            <input type="radio" name="is_top" value="{$key}" title="{$vo}" {eq name="key" value="0"}checked{/eq}>
            {/volist}
            {/notempty}
        </div>
    </div>
    <div class="layui-form-item" pane>
        <label class="layui-form-label">是否上架</label>
        <div class="layui-input-block">
            {notempty name="RadioIs"}
            {volist name="RadioIs" id="vo"}
            <input type="radio" name="is_shel" value="{$key}" title="{$vo}" {eq name="key" value="0"}checked{/eq}>
            {/volist}
            {/notempty}
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-tab layui-tab-card" lay-filter="docDemoTabBrief">
            <ul class="layui-tab-title">
                {volist name="DrawingAtlasClassification" id="vo"}
                <li {eq name="key" value="0"}class="layui-this"{/eq} data-id="{$vo.config_id}">{$vo.config_name}</li>
                {/volist}
            </ul>
            <div class="layui-tab-content">
                <!--<div class="uoload-list-this-item">
                    <a class="layui-btn layui-btn-danger layui-btn-xs"><i class="layui-icon">&#xe640;</i>删除&ensp;</a>
                    <img src="/file/drawing/atlas/20181109/6913a8a047a70e5b081085e253de35b8.jpg" class="layui-upload-img-this">
                    <input type="text" name="drawing_atlas[{$vo.config_id}][][name]"  value="">
                    <input type="hidden" name="drawing_atlas[{$vo.config_id}][][url]"  value="">
                </div>-->
                {volist name="DrawingAtlasClassification" id="vo"}
                <div class="layui-tab-item {eq name="key" value="0"}layui-show{/eq}" >
                <div class="layui-upload">
                    <button type="button" class="layui-btn" id="uoload-atlas-{$vo.config_id}">上传{$vo.config_name}</button>
                    {php}
                    $tmpArr = json_decode($dataInfo['drawing_atlas'],true);
                    $tmp = !empty($tmpArr[$vo['config_id']]['data']) ?  $tmpArr[$vo['config_id']]['data'] : "";
                    {/php}
                    <blockquote class="layui-elem-quote layui-quote-nm uoload-list-this" id="demo-uoload-atlas-{$vo.config_id}" {empty name="tmp"}style="display:none;"{/empty}>
                    {notempty name="tmp"}
                    {volist name="tmp" id="dvo"}
                    <div class="uoload-list-this-item">
                        <a class="layui-btn layui-btn-danger layui-btn-xs"><i class="layui-icon">&#xe640;</i>删除&ensp;</a>
                        <img src="{$dvo.url}" class="layui-upload-img-this">
                        <input type="hidden" name="drawing_atlas[{$vo.config_id}][title]"  value="{$vo.config_name}">
                        <input type="text" name="drawing_atlas[{$vo.config_id}][data][{$key}][name]"  value="{$dvo.name}">
                        <input type="hidden" name="drawing_atlas[{$vo.config_id}][data][{$key}][url]"  value="{$dvo.url}">
                    </div>
                    {/volist}
                    {/notempty}
                    </blockquote>
                </div>
            </div>
            {/volist}
        </div>
    </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">开间</label>
        <div class="layui-input-inline">
            <input type="text" name="open" required lay-verify="required"  placeholder="请输入开间" autocomplete="off" class="layui-input" value="{$dataInfo.open|default=''}">
        </div>
        <div class="layui-form-mid layui-word-aux">米</div>

        <label class="layui-form-label" style="margin-left: 30px;">进深</label>
        <div class="layui-input-inline">
            <input type="text" name="depth" required lay-verify="required" placeholder="请输入进深" autocomplete="off" class="layui-input" value="{$dataInfo.depth|default=''}">
        </div>
        <div class="layui-form-mid layui-word-aux">米</div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">占地面积</label>
        <div class="layui-input-inline">
            <input type="text" name="zarea" required lay-verify="required"  placeholder="请输入占地面积" autocomplete="off" class="layui-input" value="{$dataInfo.zarea|default=''}">
        </div>
        <div class="layui-form-mid layui-word-aux">平</div>

        <label class="layui-form-label" style="margin-left: 30px;">建筑面积</label>
        <div class="layui-input-inline">
            <input type="text" name="jarea" required lay-verify="required" placeholder="请输入建筑面积" autocomplete="off" class="layui-input" value="{$dataInfo.jarea|default=''}">
        </div>
        <div class="layui-form-mid layui-word-aux">平</div>
    </div>
    <div class="layui-form-item" >
        <label class="layui-form-label">造价</label>
        <div class="layui-input-block">
            <div class="layui-inline" style="margin-left: 10px;">
                <label class="layui-form-label"><i class="layui-icon">&#xe65e;</i></label>
                <div class="layui-input-inline layui-input-inline-d">
                    <input type="text" name="bprice1" value="{$dataInfo.bprice1|default='0.00'}" autocomplete="off" class="layui-input " >
                </div>
                <div class="layui-form-mid layui-word-aux">万 ~ </div>
                <div class="layui-input-inline layui-input-inline-d">
                    <input type="text" name="bprice2" value="{$dataInfo.bprice2|default='0.00'}" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">万</div>
            </div>
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">SEO关键字</label>
        <div class="layui-input-block" >
            <textarea name="seo_keyword" placeholder="请输入SEO关键字" class="layui-textarea">{$dataInfo.seo_keyword|default=''}</textarea>
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">SEO描叙</label>
        <div class="layui-input-block">
            <textarea name="seo_description" placeholder="请输入SEO描叙" class="layui-textarea">{$dataInfo.seo_description|default=''}</textarea>
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">建筑图</label>
        <div class="layui-input-block" >
            <textarea name="pbuild" placeholder="请输入建筑图内容"    class="layui-textarea topic">{$dataInfo.pbuild|default=""}</textarea>
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">结构图</label>
        <div class="layui-input-block" >
            <textarea name="pstruct" placeholder="请输入结构图内容"    class="layui-textarea topic">{$dataInfo.pstruct|default=""}</textarea>
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">给排水</label>
        <div class="layui-input-block" >
            <textarea name="pdrain" placeholder="请输入给排水内容"    class="layui-textarea topic">{$dataInfo.pdrain|default=""}</textarea>
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">电气图</label>
        <div class="layui-input-block" >
            <textarea name="peleric" placeholder="请输入电气图内容"    class="layui-textarea topic">{$dataInfo.peleric|default=""}</textarea>
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">正文内容</label>
        <div class="layui-input-block">
            <textarea name="text_content" id="text_content" placeholder="请输入正文内容">{$dataInfo.text_content|default=''}</textarea>
        </div>
    </div>
    <div class="layui-form-item my-upload-right">
        <div class="layui-upload">
            <button type="button" class="layui-btn" id="uoload-thumbnail">上传封面图</button>
            <input type="hidden" name="cover" id="thumbnail" value="{$dataInfo.cover|default=''}" placeholder="请上传封面图">
            <div class="layui-upload-list">
                <div class="layui-upload-list-title">封面图</div>
                <img class="layui-upload-img" id="thumbnail-img" src="{$dataInfo.cover|default=''}">
            </div>
        </div>
    </div>
    {empty name="SUBSTATIONS"}
    <div id="substation_type">
        <div class="layui-form-item" pane>
            <label class="layui-form-label">发布网站</label>
            <div class="layui-input-block">
                {notempty name="userSubstationList"}
                {volist name="userSubstationList" id="vo"}
                <input type="radio" name="substation_id" value="{$vo.substation_id}" title="{$vo.substation_name}">
                {/volist}
                {/notempty}
            </div>
        </div>
    </div>
    {/empty}
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" type="button" lay-submit lay-filter="formDemo">立即提交</button>
        </div>
    </div>
</form>
</body>
<script>
    var UploadIndex,count = 0,uploadImgMsg;
    layui.use(['form','upload','element'], function(){
        var form = layui.form,upload = layui.upload,element = layui.element;
        form.render();
        //监听提交
        form.on('submit(formDemo)', function(data){
            post_sub("{:url('Drawings/releaseDrawing')}",data.field);
            return false;
        });

        //缩略图上传
        var uploadInst = upload.render({
            elem: '#uoload-thumbnail'
            ,url: "{:url('Drawings/drawingUploadImg',['type'=>'DrawingCover'])}"
            ,data: {
                no: function(){
                    return $('input[name=no]').val();
                },
                no2: function(){
                    return $('select[name=no2]').val();
                }
            }
            ,before: function(obj){
                UploadIndex = layer.msg('图片上传中', {
                    icon: 16
                    ,shade: 0.01
                    ,time:0
                });
            }
            ,done: function(res){
                layer.close(UploadIndex);
                layer.msg(res.msg);
                //如果上传失败
                if(parseInt(res.code) == 0){
                    //上传成功-默认赋值
                    $("#thumbnail").val(res.url);
                    $("#thumbnail-img").attr("src",res.url);
                }
            }
        });

        {volist name="DrawingAtlasClassification" id="vo"}
        //图纸图集上传
        upload.render({
            elem: '#uoload-atlas-{$vo.config_id}'
            ,url: "{:url('Drawings/drawingUploadImg',['type'=>'DrawingAtlas'])}"
            ,multiple:true
            ,data: {
                no: function(){
                    return $('input[name=no]').val();
                },
                no2: function(){
                    return $('select[name=no2]').val();
                }
            }
            ,before: function(obj){
                count = 0;
                uploadImgMsg = "";
                UploadIndex = layer.msg('图片上传中', {
                    icon: 16
                    ,shade: 0.01
                    ,time:0
                });
            }
            ,allDone: function(obj){ //当文件全部被提交后，才触发
                layer.close(UploadIndex);
                if(count > 0) {
                    layer.msg("上传成功" + count + "个图片");
                }else{
                    layer.msg(uploadImgMsg);
                }
            }
            ,done: function(res){
                //如果上传失败
                if(parseInt(res.code) == 0){
                    count++;
                    var myIndex = $("#demo-uoload-atlas-{$vo.config_id}").find(".uoload-list-this-item").length;
                    //上传成功-默认赋值
                    $("#demo-uoload-atlas-{$vo.config_id}").css("display","block");
                    $("#demo-uoload-atlas-{$vo.config_id}").append('' +
                        '<div class="uoload-list-this-item">' +
                        '    <a class="layui-btn layui-btn-danger layui-btn-xs"><i class="layui-icon">&#xe640;</i>删除&ensp;</a>' +
                        '    <img src="'+res.url+'" class="layui-upload-img-this">' +
                        '    <input type="hidden" name="drawing_atlas[{$vo.config_id}][title]"  value="{$vo.config_name}">' +
                        '    <input type="text" name="drawing_atlas[{$vo.config_id}][data]['+myIndex+'][name]"  value="">' +
                        '    <input type="hidden" name="drawing_atlas[{$vo.config_id}][data]['+myIndex+'][url]"  value="'+res.url+'">' +
                        '</div>');
                    del_atlas_del($("#demo-uoload-atlas-{$vo.config_id}").find(".uoload-list-this-item:last"));//设置删除事件
                }else{
                    uploadImgMsg = res.msg;
                }
            }
        });
        {/volist}
    });
    $(function () {
        //百度编辑器初始化
        UE.getEditor('text_content',{
            initialFrameWidth:'100%',
            initialFrameHeight: 500,
        });
        $(".layui-upload .layui-upload-list").click(function () {
            $('#uoload-thumbnail').trigger('click');
        });
        //标题关键字获取
        $("#getKeywords").click(function () {
            UploadIndex = layer.msg('请求中', {
                icon: 16
                ,shade: 0.01
                ,time:0
            });
            $.post("{:url('Other/getKeyword')}", {str:$("input[name=topic]").val()}, function (data, status) {
                layer.close(UploadIndex);
                $("input[name=keywords]").val(data);
            });
        });
        //绑定删除图集事件
        $(".uoload-list-this-item").each(function () {
            del_atlas_del($(this));
        });
    });
    //删除图集事件
    function del_atlas_del(item) {
        item.find(".layui-btn-xs").click(function () {
            if(item.parent(".uoload-list-this").find(".uoload-list-this-item").length <= 1) {
                item.parent(".uoload-list-this").css("display","none");
            }
            item.remove();
        });
    }
</script>
</html>